package com.ybkj.o2o.zhuanche.entity;

import com.fasterxml.jackson.annotation.JsonGetter;

import java.beans.Transient;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.List;


public class ChartMonth extends Base {

  private static final long serialVersionUID = -4006303565058471642L;

  private Long yearId;

  private int month;

  private long totalSuccessNum;// 已成交单量

  private long totalCancelNum;// 已销单量

  private BigDecimal totalPrice;// 总价

  private List<ChartDay> chartDays;

  private String appKey;

  public String getAppKey() {
    return appKey;
  }

  public void setAppKey(String appKey) {
    this.appKey = appKey;
  }

  public Long getYearId() {
    return yearId;
  }

  public void setYearId(Long yearId) {
    this.yearId = yearId;
  }

  public long getTotalSuccessNum() {
    return totalSuccessNum;
  }

  public void setTotalSuccessNum(long totalSuccessNum) {
    this.totalSuccessNum = totalSuccessNum;
  }

  public long getTotalCancelNum() {
    return totalCancelNum;
  }

  public void setTotalCancelNum(long totalCancelNum) {
    this.totalCancelNum = totalCancelNum;
  }
  /**
   * 如果为空则返回0.
   */

  public BigDecimal getTotalPrice() {
    if (null == totalPrice) {
      return new BigDecimal(0);
    }
    return totalPrice;
  }

  public void setTotalPrice(BigDecimal totalPrice) {
    this.totalPrice = totalPrice;
  }

  public int getMonth() {
    return month;
  }

  public void setMonth(int month) {
    this.month = month;
  }

  public List<ChartDay> getChartDays() {
    return chartDays;
  }

  public void setChartDays(List<ChartDay> chartDays) {
    this.chartDays = chartDays;
  }
  /**
   * 获取一个月最大的一天.
   */

  @Transient
  @JsonGetter
  public int getDays() {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.MONTH, getMonth());

    return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);// 获取每月最大一天
  }
}
